/*
 *  Copyright:  (C) 2018 LingYun IoT System Studio
 *              All rights reserved.
 *
 *  File name:  syserr.c
 *Description:  Test between perror() and strerror().
 *
 *    Version:  1.1
 *     Author:  Guo Wenxue <guowenxue@gmail.com>
 *		        Copied by Zhu Tianyin <zhuty_cn@163.com>
 *  ChangeLog:  1.0  Release initial version in 2018.
 *              1.1  Copy and change some details on "01/06/2021".
 */
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

int main(int argc, char **argv)
{
	char *file_name = "/test.txt";
	int fd = -1;
	
	fd = open(file_name, O_RDONLY, 066);
	if( fd < 0 )
	{
		perror("Open file failure");
		printf("Open file %s failure: %s\n", file_name, strerror(errno));
		return 0;
	}
	close(fd);
}
